home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / swmeter / logit.arc / LOGIT.PAS
Pascal/Delphi Source File  |  1988-03-05  |  4KB  |  161 lines

  1. Program LogIt;  { A program to log a Novell LAN users activity }
  2. Uses
  3.   DOS,
  4.   TpString,
  5.   TpCmdLin;
  6. type
  7.   str79        = string[79];
  8.   logentrytype = record
  9.                    PacketLength : Word;
  10.                    Func         : Byte;
  11.                    Message      : Str79;
  12.                  end;  { record }
  13.  
  14. Var
  15.   ReplyBuff : Word;
  16.   I,N       : Integer;
  17.   Tmp       : string;
  18.   PS        : ^String;
  19.  
  20. (* **********************************************************************
  21.  
  22. Generally, this program will do the following:
  23.  
  24.      Log the date and time that a program is called and
  25.      later, when it was finished.
  26.  
  27. Usage:
  28.      Call from a batch file or the Novell menu system.
  29.      Ie:  Logit start "Entering Accounting System"
  30.      or   Logit stop "Finished with Word Processing"
  31.  
  32. A typical menu system entry might look like this:
  33.  
  34.      1) TCS Accounting
  35.           Logit Start "Entering TCS"
  36.           f:
  37.           pushdir
  38.           cd\tcs
  39.           quick
  40.           popdir
  41.           Logit Stop "Finished with TCS"
  42.  
  43. ************************************************************************ *)
  44.  
  45. Function GetLoginName : string;
  46. type
  47.   ReqType = record
  48.               PacketLength : Word;
  49.               Func         : Byte;
  50.               CN           : Byte;
  51.             end;   { record }
  52.   RepType = record
  53.               ReturnLength : Word;
  54.               UniqueID     : LongInt;
  55.               Typ          : Word;
  56.               Name         : Array[1..48] of char;
  57.               LogTime      : Array[1..8] of char;
  58.             end;   { record }
  59.               
  60. var
  61.   regs    : registers;
  62.   ReqBuff : ReqType;
  63.   RepBuff : Reptype;
  64.   NameStr : string;
  65. begin
  66.   with regs do
  67.     begin
  68.       AH := $DC;
  69.       MSDOS(regs);
  70.  
  71.       ReqBuff.PacketLength := 2;
  72.       ReqBuff.Func := $16;
  73.       ReqBuff.CN := AL;
  74.       AH := $E3;
  75.       DS := Seg(ReqBuff);
  76.       SI := Ofs(ReqBuff);
  77.       ES := Seg(RepBuff);
  78.       DI := Ofs(RepBuff);
  79.  
  80.       MSDOS(regs);
  81.  
  82.       i := 0;
  83.       Repeat
  84.         i := succ(i);
  85.         namestr[i] := repbuff.Name[i];
  86.       Until RepBuff.Name[i] = #0;
  87.       namestr[0] := chr(i);
  88.       GetLoginName := namestr;
  89.     end;
  90. end;  { function GetLoginName }  
  91.  
  92. procedure Log(action : byte; entry : str79);
  93. var
  94.   regs     : registers;
  95.   logentry : logentrytype;
  96.   tmpstr   : string;
  97.   pl       : word;
  98. begin
  99.   with regs do
  100.     begin
  101.       AH := $E3;
  102.       DS := Seg(logentry);
  103.       SI := Ofs(logentry);
  104.       ES := Seg(ReplyBuff);
  105.       DI := Ofs(ReplyBuff);
  106.       logentry.Func := $0D;
  107.       case action of
  108.         1 : TmpStr := GetLoginName + ' | Begin | ' + entry;
  109.         2 : TmpStr := GetLoginName + ' | End   | ' + entry;
  110.       else
  111.         TmpStr := GetLoginName + ' |       | ' + entry;
  112.       end;  { of case }
  113.       if length(TmpStr) > 79 Then
  114.         TmpStr[0] := #79;
  115.       pl := length(TmpStr) + 2;
  116.       LogEntry.PacketLength := pl;
  117.       LogEntry.Message := TmpStr;
  118.  
  119.       MSDOS(regs);
  120.     end;  { with regs }
  121. end;  { procedure log }
  122.  
  123. Procedure QuitAndHelp;
  124. Begin
  125.   WriteLn;
  126.   WriteLn;
  127.   Writeln('     LogIt (C) 1988 by Micro Networks of America, Inc.');
  128.   Writeln;
  129.   WriteLn('     Usage:  LogIt [Action] "Text"');
  130.   WriteLn;
  131.   WriteLn('     Where Action is optional.  Valid Actions are Start or Stop.');
  132.   WriteLn;
  133.   WriteLn('     Text is the actual comment to log.  Maximum length is 40 characters.');
  134.   WriteLn;
  135.   WriteLn('     Examples:  LogIt Start "Accounting Software"  ');
  136.   WriteLn('                LogIt Stop  "Accounting Software" ');
  137.   WriteLn;
  138.   WriteLn('     A supervisor level user may view the log by nprinting, ');
  139.   WriteLn('     typing, or using an ascii text editor to view a file in ');
  140.   WriteLn('     the SYS:SYSTEM directory called NET$LOG.MSG ');
  141.   WriteLn;
  142.   Halt(1);
  143. End;
  144.  
  145. Begin
  146.   PS := Ptr(PrefixSeg, $80);
  147.   N := ParamCnt(PS^);
  148.   If N > 0 then
  149.     begin
  150.       I := 0;
  151.       tmp := StUpCase(GetArgString(I,False,False));
  152.       I := 1;
  153.       if tmp = 'START' Then
  154.         Log(1,GetArgString(I,True,False));
  155.       if tmp = 'STOP' Then
  156.         Log(2,GetArgString(I,True,False));
  157.     end
  158.   else
  159.     QuitAndHelp;
  160. End.
  161.